#ifndef _IM_SERVER_UID_COMET_CONN_MAP_
#define _IM_SERVER_UID_COMET_CONN_MAP_

#include <string>
#include <boost/unordered_map.hpp>
#include <boost/thread/mutex.hpp>
#include "comet_connection.h"
#include "base/logging.h"
#include "base/singleton.h"
#include <vector>

namespace imserver {

class UidCometConnMap : public base::Singleton<UidCometConnMap> {
 public:
  void add(int64_t uid, CometConnectionPtr conn);
  void remove(int64_t uid);
  bool get(int64_t uid, CometConnectionPtr& conn);
  //bool contains(int64_t uid);

  const static int BUCKET_COUNT = 20;
 private:
  friend class base::Singleton<UidCometConnMap>;

  UidCometConnMap() {}
  ~UidCometConnMap() {}

  typedef boost::unordered_map<int64_t, CometConnectionPtr> MapType;
  std::vector<MapType> uid_conn_maps_;
  boost::mutex mutexies[BUCKET_COUNT];
};

}

#endif // _IM_SERVER_UID_COMET_CONN_MAP_

